package cn.com.zzz.dao;

import cn.bbs.ba.base.BADomain;
import cn.bbs.ba.base.UserInfo;
import cn.bbs.ba.dao.BAADaoOperate;
import cn.bbs.ba.db.Fetcher;

public class PPUserInfoDao extends BADomain {

	/**
	 * 检查用户登陆
	 * @param puserInfo UserInfo
	 * @return 得到的用户
	 */
	public UserInfo getUser(UserInfo puserInfo) {
		
		puserInfo.setSQLID("searchUserInfoByUser");
		
		Fetcher<UserInfo> retFetch = BAADaoOperate.search(puserInfo, UserInfo.class);
		
		UserInfo userInfo = null;
		if (retFetch.size() > 0) {
			userInfo = retFetch.get(1);
		}
		return userInfo;
	}
	
	/**
	 * 检查用户是否存在
	 * @param puserInfo UserInfo
	 * @return 得到的用户
	 */
	public UserInfo checkUserEx(UserInfo puserInfo) {
		
		puserInfo.setSQLID("searchUserInfoEx");
		
		Fetcher<UserInfo> retFetch = BAADaoOperate.search(puserInfo, UserInfo.class);
		
		UserInfo userInfo = null;
		if (retFetch.size() > 0) {
			userInfo = retFetch.get(1);
		}
		return userInfo;
	}
	
	/**
	 * 检查用户是否存在
	 * @param puserInfo UserInfo
	 * @return 得到的用户
	 */
	public UserInfo getMaxUser() {
		UserInfo puserInfo = new UserInfo();
		puserInfo.setSQLID("searchUserMaxNo");
		
		Fetcher<UserInfo> retFetch = BAADaoOperate.search(puserInfo, UserInfo.class);
		
		UserInfo userInfo = null;
		if (retFetch.size() > 0) {
			userInfo = retFetch.get(1);
		}
		return userInfo;
	}
	
	/**
	 * 插入用户表
	 * @param puserInfo UserInfo
	 * @return 得到的用户
	 */
	public int insertUserInfo(UserInfo puserInfo) {
		
		puserInfo.setSQLID("insertPPUserInf");
		
		int iCount = BAADaoOperate.update(puserInfo);
		
		return iCount;
	}
	/**
	 * 根据用户ID更新用户表
	 * @param puserInfo UserInfo
	 * @return 更新条数
	 */
	public int updateUserInfoByUserNo(UserInfo puserInfo) {
		
		puserInfo.setSQLID("updatePPUserByUserNO");
		
		int iCount = BAADaoOperate.update(puserInfo);
		
		return iCount;
	}
	
	/**
	 * 取机器人
	 * @param puserInfo UserInfo
	 * @return 得到的用户
	 */
	public Fetcher<UserInfo> getJiqiRen(UserInfo puserInfo) {
		
		puserInfo.setSQLID("searchUserBykbn");
		Fetcher<UserInfo> retFetch = BAADaoOperate.search(puserInfo, UserInfo.class);
		return retFetch;
	}
}
